package com.bj.disc.ui.login.dialog

import android.app.Activity
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.widget.PopupWindow
import com.ai3d.rfid.R
import com.ai3d.rfid.databinding.DialogCheckLanguageBinding

/**
 * @ProjectName : Trias
 * @Author : weijinsong
 * @Time : 2023/5/30 9:14
 * @Description : 文件描述
 */
class CheckPointDetailDialog(private val activity: Activity) : PopupWindow(activity) {

    val binding: DialogCheckLanguageBinding by lazy {
        DialogCheckLanguageBinding.inflate(LayoutInflater.from(activity))
    }

    init {
        contentView = binding.root
//        contentView.setOnClickListener { dismiss() }
//        initView()
//        width= ViewGroup.LayoutParams.MATCH_PARENT
//        height= ViewGroup.LayoutParams.MATCH_PARENT
        isOutsideTouchable=true
        isFocusable=true
        setBackgroundDrawable(activity.getDrawable(R.drawable.layer_check_language_dialog))
    }

    var onOkListener: (() -> Unit)? = null

    private fun initView() {
//        binding.llContent.setOnClickListener {  }
//        binding.tvCancel.setOnClickListener {
//            dismiss()
//        }
//        binding.tvOk.setOnClickListener {
//            onOkListener?.invoke()
//        }
    }

    fun show(view: View) {
        if (activity.window.decorView.windowToken != null) {
//            showAtLocation(view, Gravity.BOTTOM, 0, 0)
//            showAsDropDown(view)
            showAsDropDown(view,0, 0, Gravity.BOTTOM)
        }
    }

//    fun setCheckPointDetail(checkPointDetailResp: CheckPointDetailResp?) {
//        if (null != checkPointDetailResp) {
//            binding.tvDate.text = DateFormatUtils.long2Str(
//                checkPointDetailResp?.data.checkDate,
//                DATE_FORMAT_PATTERN_YMD_HM
//            )
//
//            if (checkPointDetailResp.data.statusCode == "0") {//正常
//                binding.ivStatus.setBackgroundResource(R.mipmap.water_status_blue)
//                binding.tvCurValue.setTextColor(
//                    ContextCompat.getColor(
//                        activity,
//                        R.color.text_main_color
//                    )
//                )
//            } else {
//                binding.ivStatus.setBackgroundResource(R.mipmap.water_status_red)
//                binding.tvCurValue.setTextColor(Color.RED)
//            }
//
//            binding.tvStatusContent.text = checkPointDetailResp.data.alarmType
//            binding.tvCurValue.text = checkPointDetailResp.data.pressureKg
//        }
//    }
}
